package com.study.controller;

import com.study.annotation.SystemControllerLog;
import com.study.common.EasyUIDataGridResult;
import com.study.dbo.ManagerDO;
import com.study.service.ManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.validation.Valid;
import java.util.List;

/*********************************************************
 * @Author ONE_LLX
 * @Description //TODO 
 * @Date 10:54 2019/10/11
 * @Class ManagerController
 * @Version v1.0
 *********************************************************/
@CrossOrigin(origins = "*", maxAge = 3600, methods = {RequestMethod.POST, RequestMethod.GET})
@RestController
@RequestMapping("manager")
public class ManagerController {

    @Autowired
    @Qualifier("managerService")
    private ManagerService managerService;


    @SystemControllerLog(description = "查询公司简介")
    @RequestMapping(value = "/find/list",method = RequestMethod.GET,produces = "application/json;charset=UTF-8")
    public List<ManagerDO> findList(){
//        System.out.println(1/0);
        return managerService.findList();
    }


    @SystemControllerLog(description = "查询公司简介")
    @RequestMapping(value = "/add",method = RequestMethod.GET,produces = "application/json;charset=UTF-8")
    public Boolean insertManager(@RequestParam String name,
                                 @RequestParam String passwd){
        managerService.insertManager(name, passwd);
        return true;
    }


    @SystemControllerLog(description = "后台管理员账号密码登录")
    @RequestMapping(value = "/login",method = RequestMethod.GET,produces = "application/json;charset=UTF-8")
    public Boolean login(@RequestParam String name,
                         @RequestParam String passwd,
                         HttpSession session,
                         HttpServletRequest request,
                         HttpServletResponse response) throws Exception {

        return null;

    }

    @SystemControllerLog(description = "分页查询列表")
    @RequestMapping(value = "/list/page",method = RequestMethod.GET,produces = "application/json;charset=UTF-8")
    public EasyUIDataGridResult findListByPage(@RequestParam Integer page,
                                               @RequestParam Integer rows){
        return managerService.findListByPage(page, rows);
    }
}
